$(document).ready(function()
{
    // Các nút phân trang
    $('.pagination-order-number a').live('click', function() { return false; });
    $('.pagination-order-number a:not(.selected)').live('click', function()
    {
        var page = $(this).text();
        loadPaging({page: page});
    });

    $('#ct-timkiem-form').submit(function() {
        var text = '%' + $('#ct-timkiem-keyword').val() + '%';
        loadPaging({page: 1, keyword: text});
    });

    function loadPaging(params)
    {
        $.post('ajax_controller.php', {
            requestType: 'PGlobal',
            requestName: 'getPhonePagination',
            requestParams: params
        }, function(data)
        {
            $('.main-data').html(data['data']);

            $('.pagination-order-number').html(data['paging']);
        }, 'json');
    }

    $('a.admin-dienthoai-delete').live('click', function()
    {
        var id = $(this).metadata().id;

        $.post('ajax_controller.php', {
            requestType: 'DienThoai',
            requestName: 'del',
            requestParams: id
        }, function(data)
        {
            if (data == '1') {
                $('tr#row-' + id).remove();
            } else {
                Dialog.show(data, false, true);
            }
        });

        return false;
    })
});
